import Mock from "mockjs";
const Random = Mock.Random;

Mock.Random.extend({
    fundtype(){
        var list=['stock_fund','hybrid_fund','bond_fund']
        return this.pick(list)
    }
});
// mock基金方案对象
export const mockfundplans = function () {
  let list = [];
   var one=1.0
  // 模拟一个object对象，键为pk和fields，其中field指向另一个对象，里面是实体类
  for (let i = 0; i < 5; i++) {
    var proportion = Random.float(0,1,3,4)*0.2
    const object = Mock.mock({
        'id|1-100':1,
        fund_id:'1',
        fund_proportion:(i==4?one:proportion).toFixed(4),
        user_id:'1',
        fund_name:'基金'+'@natural(1,100)',
        fund_type:'@fundtype',
    });
    one-=proportion
    list.push(object);
  }

  return {
    
    data: list,
    flag: true,
  };
};
